home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Windows / WindowObject.h < prev    next >
Text File  |  1997-06-28  |  4KB  |  129 lines

  1. // WindowObject.h
  2.  
  3. #ifndef WindowObject_h
  4. #define WindowObject_h
  5.  
  6. #ifndef __WINDOWS__
  7. #include <Windows.h>
  8. #endif
  9. #ifndef ConstPString_h
  10. #include "ConstPString.h"
  11. #endif
  12. #ifndef Str_h
  13. #include "Str.h"
  14. #endif
  15. #ifndef PointObject_h
  16. #include "PointObject.h"
  17. #endif
  18. #ifndef Rectangle_h
  19. #include "Rectangle.h"
  20. #endif
  21. #ifndef GrafPortObject_h
  22. #include "GrafPortObject.h"
  23. #endif
  24.  
  25. class WindowObject: public WindowRecord
  26.   {
  27.     private:
  28.         // not implemented:
  29.             WindowObject( const WindowObject& );
  30.             void operator=( const WindowObject& );
  31.  
  32.         WStateData& StateData();
  33.         const WStateData& StateData() const;
  34.     
  35.     public:
  36.         enum Definition
  37.           {
  38.             noZoom                = documentProc,
  39.             dialog                = dBoxProc,
  40.             plain                    = plainDBox,
  41.             shadowed                = altDBoxProc,
  42.             noGrowNoZoom        = noGrowDocProc,
  43.             movableModal        = movableDBoxProc,
  44.             document                = zoomDocProc,
  45.             noGrow                = zoomNoGrow,
  46.             rounded                = rDocProc
  47.           };
  48.         
  49.         WindowObject( Definition = document, bool withCloseBox = true );
  50.         
  51.         ~WindowObject()                                        { CloseWindow( &port ); }
  52.         
  53.         void Select()                                            { SelectWindow( &port ); }
  54.         void SendBehind( WindowObject& w )                { ::SendBehind( &port, &w.port ); }
  55.         void SendToBack()                                        { ::SendBehind( &port, 0 ); }
  56.         
  57.         uint32 Index() const;
  58.         void SetIndex( uint32 );
  59.         
  60.         void Show()                                                { ShowWindow( &port ); }
  61.         void Hide()                                                { HideWindow( &port ); }
  62.         
  63.         void SetTitle( ConstPString s )                    { SetWTitle( &port, s ); }
  64.         void GetTitle( String255& s ) const             { GetWTitle( const_cast<WindowPtr>(&port), s ); }
  65.         
  66.         PointObject Position() const                        { return Port().GlobalBounds().TopLeft(); }
  67.         void SetPosition( PointObject p )                { MoveWindow( &port, p.h, p.v, false ); }
  68.         void MoveByDragging( PointObject mouse )        { DragWindow( &port, mouse, &Rectangle::big ); }
  69.         
  70.         PointObject Size() const                            { return Port().LocalBounds().Size(); }
  71.         void SetSize( PointObject size )                    { SizeWindow( &port, size.h, size.v, true ); }
  72.         PointObject SizeByDragging( PointObject mouse,
  73.                                              PointObject minimum,
  74.                                              PointObject maximum );
  75.         
  76.         Rectangle GlobalBounds() const                    { return Port().GlobalBounds(); }
  77.         void SetBounds( Rectangle );
  78.         
  79.         Rectangle UserBounds() const                        { return StateData().userState; }
  80.         void SetUserBounds( Rectangle r )                { StateData().userState = r; }
  81.         
  82.         Rectangle StandardBounds() const                    { return StateData().stdState; }
  83.         void SetStandardBounds( Rectangle r )            { StateData().stdState = r; }
  84.         
  85.         bool TrackZoomInBox( PointObject mouse )        { return TrackBox( &port, mouse, inZoomIn ); }
  86.         bool TrackZoomOutBox( PointObject mouse )        { return TrackBox( &port, mouse, inZoomOut ); }
  87.         bool TrackCloseBox( PointObject mouse )        { return TrackGoAway( &port, mouse ); }
  88.         
  89.         void ZoomToUserBounds();
  90.         void ZoomToStandardBounds();
  91.         
  92.         Rectangle LocalBounds() const                        { return Port().LocalBounds(); }
  93.         
  94.         uint32 RefCon() const                                { return GetWRefCon( const_cast<WindowPtr>( &port ) ); }
  95.         void SetRefCon( uint32 r )                            { SetWRefCon( &port, r ); }
  96.  
  97.         static WindowObject *Front()                        { return reinterpret_cast<WindowObject *>( FrontWindow() ); };
  98.         WindowObject *Next()                                    { return static_cast<WindowObject *>( nextWindow ); }
  99.         
  100.         GrafPortObject& Port()                                { return static_cast<GrafPortObject&>( port ); }
  101.         const GrafPortObject& Port() const                { return static_cast<const GrafPortObject&>( port ); }
  102.         
  103.         int16 Kind() const                                    { return windowKind; }
  104.         bool Visible() const                                    { return visible != 0; }
  105.         bool Highlighted() const                            { return hilited != 0; }
  106.         bool HasCloseBox() const                            { return goAwayFlag != 0; }
  107.         bool HasZoomBox() const                                { return spareFlag != 0; }
  108.         
  109.         RgnHandle StructureRegion() const                { return strucRgn; }
  110.         RgnHandle ContentRegion() const                    { return contRgn; }
  111.         RgnHandle InvalidRegion() const                    { return updateRgn; }
  112.         RgnHandle VisibleRegion() const                    { return port.visRgn; }
  113.         
  114.         int16 TitleWidth() const                            { return titleWidth; }
  115.         
  116.         ControlHandle FirstControl() const                { return controlList; }
  117.         
  118.         void SetVisibility( bool visible )                { ShowHide( &port, visible ); }
  119.         void SetHighlighting( bool highlighted )        { HiliteWindow( &port, highlighted ); }
  120.         
  121.         GDHandle NearestScreen() const;
  122.         GDHandle DeepestScreen() const;
  123.         
  124.         static uint32 CountVisibleWindows();
  125.         static uint32 CountVisibleWindows( Rectangle );
  126.   };
  127.  
  128. #endif
  129.